/*
指针
https://www.bilibili.com/video/BV1gf4y1r79E/?p=10&spm_id_from=pageDriver&vd_source=8bd7b24b38e3e12c558d839b352b32f4
*/
package main

import "fmt"

func changeVal(p *int) {
	*p = 10
}

func swap(a *int, b *int) {
	var tmp int = *a
	*a = *b
	*b = tmp
}

func main() {
	// 改变
	fmt.Println("pointer!")
	var a int = 1
	changeVal(&a)
	fmt.Println(a)

	// 交换
	var b int = 20
	fmt.Println("%d, %d", a, b)
	swap(&a, &b)
	fmt.Println("%d, %d", a, b)

	// 二级指针
	var p *int = &a
	fmt.Println(p)
	fmt.Println(&a)
	var pp **int = &p
	fmt.Println(pp)
	fmt.Println(&p)
}
